<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>注册</title>
    <link rel="stylesheet" type="text/css" th:href="@{../static/css/register.css}" />
</head>

<body>
    <div id="reg">
        <div id="left">
            <br>
            <h1>立即注册</h1>
            <form method="post" action="/add/user" id="regform">
                <p>
                    昵称<br>
                    <input type="text" id="ni" placeholder="请输入您的昵称" name="name" required>
                </p>
                <p>
                    用户名<br>
                    <input type="text" id="un"  placeholder="请输入您的用户名" name="username" required>
                </p>
                <p>
                    密码<br>
                    <input type="password" id="pwd" placeholder="密码长度至少为6位，且为数字与字母的组合" name="password" required>
                </p>
                <p>
                    确认密码<br>
                    <input type="password" id="ag" placeholder="两次密码须一致" required>
                </p>
                <br>
                <input type="button" value="注册" id="zhu">
            </form>
            <span th:text="${ishave}" style="color: red" id="errormsg"></span>
        </div>

        <div id="right">
            <br><br><br>
            <h2 class="wh">已有账号？</h2>
            <p class="wh">欢迎回来，立即登录吧！</p>
            <br><br><br><br><br><br><br><br><br><br><br><br><br><br>
            <a href="/login/toLogin"><button id="dl">登录</button></a>
        </div>

    </div>

<script>
    var zhu = document.getElementById("zhu");
    var errormsg = document.getElementById("errormsg");
    zhu.onclick = function (){
        if(document.getElementById("pwd").value===document.getElementById("ag").value){
            errormsg.innerText=""
            document.getElementById("regform").submit();
        }else {
            errormsg.innerText="两次密码不一致！"
        }
    }
</script>

</body>

</html>